Skip to content

feat(sidebar): 最近会话行首显示最后一轮使用的模型图标 - #735

Merged
su-fen merged 1 commit into
Stack-Cairn:mainfrom
AlphaCatMeow:feat/sidebar-provider-icon
Sep 4, 2026
Merged

feat(sidebar): 最近会话行首显示最后一轮使用的模型图标#735
su-fen merged 1 commit into
Stack-Cairn:mainfrom
AlphaCatMeow:feat/sidebar-provider-icon

Conversation

@AlphaCatMeow

@AlphaCatMeow AlphaCatMeow commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Closes #734

Summary

侧栏「最近会话」每行只有标题,多供应商混用时看不出会话用的是哪个模型。本 PR 在每行标题左侧加一个 16px 供应商 logo,依据是最后一轮对话实际使用的模型——chatHistoryprovider_id 每轮 upsert 覆写,天然就是这个语义,前端数据也已透传到 SidebarConversation,因此不涉及后端和数据结构变更:

  • 新增共享组件 ProviderBrandIcon,并导出 isKnownProviderId 白名单守卫。侧栏的 providerId 是宽 string:老数据存的是空串、GUI 乐观行可能回退 "pending"、Web 端乐观行存的是自定义供应商实例 id。这些值不能进现有图标组件的 fallback 分支(会错显示成 OpenAI logo),守卫只放行五个枚举值,未命中不渲染图标、标题顶格;
  • 图标悬停时原生 title 显示具体模型名,悬停行内其他区域仍显示会话标题(HTML title 取最内层元素,无冲突);多选模式下图标隐藏,让位给同为 h-4 w-4 的 checkbox,标题位置不跳动;
  • areRenderedHistoryItemsEqual 补比较 providerId / model:该 memo 比较函数此前不含这两个字段,行内一旦展示模型信息,换模型后新一轮持久化时行不会重渲染,图标会停留在旧值。store 层 reconcile.ts 本就比较这两个字段,item 引用只在字段真变时更换,不会引入多余重渲染;
  • 顺手把 ComposerModelControlsmodelPicker 里两份字节等价的私有 ProviderBrandIcon 收敛到共享组件;ProviderPresentation 的版本尺寸契约不同(height="1em" 随文字缩放),保留并留了 TODO。

侧栏行组件在 agent-ui 由 GUI 与 WebUI 共用,一处改动两端生效。

Change scope

  • Modules: agent-ui(GUI / WebUI 共享)
  • Key paths:
    • crates/agent-ui/src/components/ProviderBrandIcon.tsx(新增)
    • crates/agent-ui/src/components/chat/ChatHistorySidebarRows.tsx(行首图标 + memo 修复)
    • crates/agent-ui/src/components/chat/ComposerModelControls.tsx(私有副本收敛)
    • crates/agent-ui/src/pages/settings/modelPicker.tsx(私有副本收敛)
    • crates/agent-ui/src/pages/settings/ProviderPresentation.tsx(仅注释)

Screenshots / preview

86862bfcfff6b23746d9ce8280f49c51

Verification

  • pnpm typecheck:ui
  • biome check 新增文件无诊断;lint:ui 全仓与 main 基线错误数一致(480,均为本机 CRLF 存量格式问题),本 PR 未新增
  • pnpm test:webui 685/685 ✅
  • pnpm test:gui 2898 pass / 5 fail,失败集与 main 基线完全一致(已在无改动基线上复跑确认),与本 PR 无关
  • 桌面端 dev 客户端人工验证:各供应商会话行 logo 正确(codex 显示 OpenAI 图标)、悬停图标显示模型名、空 provider_id 行不渲染图标、多选模式图标隐藏、换模型后新一轮对话持久化时图标更新

Pre-submit checklist

  • A requirement issue is linked (or this is a trivial fix that needs no issue, as explained in the summary).
  • Synced with the target branch; no merge conflicts.
  • The change is focused, with no unrelated modifications.
  • No secrets, tokens, or personal data included.
  • Docs are updated for changes affecting user behavior, deployment, or configuration.

- Add shared ProviderBrandIcon component with isKnownProviderId guard
  (legacy rows persist "", optimistic rows may carry "pending" or a
  custom provider instance id — only enum hits render an icon)
- Render the icon left of the row title, hidden in selection mode;
  native title tooltip shows the last-used model name
- Compare providerId/model in areRenderedHistoryItemsEqual so rows
  re-render after a new turn persists a different model
- Converge two byte-identical private ProviderBrandIcon copies
  (ComposerModelControls, modelPicker) onto the shared component
@StackCairn
StackCairn marked this pull request as draft September 2, 2026 12:44
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR governance checks passed. Awaiting human review.

@AlphaCatMeow
AlphaCatMeow marked this pull request as ready for review September 2, 2026 12:47
@su-fen
su-fen merged commit ef0c661 into Stack-Cairn:main Sep 4, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 最近会话列表行首显示最后一轮使用的模型图标

2 participants